﻿//  --------------------------------
//  Copyright (c) 2010 Michael Schuler, Sascha Burger. All rights reserved.
//  This source code is made available under the terms of the Microsoft Public License (Ms-PL)
//  http://p2pmessaging.codeplex.com/license
//  ---------------------------------
using System;
using System.Collections.Generic;
using p2pMessaging.Interfaces;
using p2pMessaging.Interfaces.Contact;

namespace p2pMessaging.BL.Model
{
	[Serializable]
	public sealed class Message : IMessage
	{
		private readonly List<IContact> myRecipients = new List<IContact>();
		
		public Message()
		{
			Id = Guid.NewGuid().ToString();
			myRecipients = new List<IContact>();
		}

		public Guid PluginId { get; set; }
		
		public string Id { get; set; }
		
		public string Subject { get; set; }
		
		public IContact Sender { get; set; }

		public List<IContact> Recipient
		{
			get { return myRecipients; }
		}

		public string Data { get; set; }

		public override int GetHashCode()
		{
			return Id.GetHashCode();
		}

		public override bool Equals(object obj)
		{
			if (obj == null || obj.GetType() != typeof(Message))
			{
				return false;
			}
			
			return Id.Equals(((Message) obj).Id);
		}
	}
}
